<template>
    <a-card>
        <p-cs :categorys="categorys" :defaultChecked="defaultChecked" :scope="conditionScope" :wxlink="wxlink" :default="defaultCondition" @callback="evt"  />
        <a-button type="primary" @click="findUserMgrScope" >获取用户管理范围</a-button>
    </a-card>
</template>
<script>
import cs from '@/components/Power/BizComponents/CustomerScreening/CustomerScreen.vue'
import { findUserManagerScope } from '@/utils/comm.js'
export default {
    data () {
        return {
            categorys: [],
            defaultChecked: 'group',
            defaultCondition: null,
            conditionScope: null,
            wxlink: false
        }
    },
    created () {
        // let condition = {
        //     "type" : "biz",
        //     "params" : [ 
        //         {
        //             "order" : 0,
        //             "operator" : 0,
        //             "attrvalues" : [ 
        //                 {
        //                     "keyid" : 8006,
        //                     "keyvalue" : "四",
        //                     "operator" : 0,
        //                     "fuzzy" : true,
        //                     "order" : 0
        //                 }
        //             ]
        //         }
        //     ],
        //     "operator" : 0,
        //     "scope" : {
        //         "ids" : [ 
        //             2
        //         ],
        //         "type" : "org"
        //     }
        // }
        let condition = {
            "type" : "group",
            "params" : [
                {id: "wradNhCgAA0Gl_HGwZZAamExEPdTj87Q", name: "测试群2", owner: "熊军", ownerid: "13687086095"},
                {id: "wradNhCgAAZtQS_gyXiT0HDnDLYM3uVA", name: "测试群1", owner: "熊军", ownerid: "13687086095"}
            ],
            "operator" : 1,
            "scope" : {
                "ids" : [ 
                    2
                ],
                "type" : "org"
            }
        }
        this.defaultChecked = condition.type;
        this.conditionScope = condition.scope;
        this.defaultCondition = condition;
    },
    methods: {
        evt (data) {
            console.log(data)
        },
        findUserMgrScope () { // 获取用户管理范围
            let user = {isadmin: false, scope: 1, department: [{path: [4, 1], isleader: true, name: "客服部2", id: 4}], userid: '17370022303'}
            let scope = findUserManagerScope(user)
            console.log('scope', scope)
        }
    },
    components: {
        'p-cs': cs
    }
}
</script>